function verifyPostorder(arr) {
  var length = arr.length;
  var root = arr[length - 1];

  if (length < 2) return true;
  //判断 cut位置
  let cut = 0
  for ( cut = 0; arr[cut] < root && cut < length - 1; ++cut) {}
  console.log(cut);
  
  // console.log(cut); cut为右子树开头
  for (let i = cut; i < length - 1; ++i) {
    if (arr[i] < root) {
      return false;
    }
  }
  return (
    verifyPostorder(arr.slice(0, cut)) &&
    verifyPostorder(arr.slice(cut, length - cut - 1))
  );
}
console.log(verifyPostorder([4,8,6,12,16,14,10]));

